﻿using Digitalmes.Domain.Entities.Mes.Masters;

namespace Digitalmes.Application.Mes.Masters.Materials.Commands;

/// <summary>
/// 删除物料命令。
/// </summary>
/// <param name="MaterialId"></param>
public record DeleteMaterialCommand(long MaterialId) : IRequest<IResult<bool>>;

internal sealed class DeleteMaterialCommandHandler(IRepository<MdMaterial> repo) : IRequestHandler<DeleteMaterialCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteMaterialCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.MaterialId, cancellationToken);
        return Result.From(ok);
    }
}
